package com.jia;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;

/**
 * User: xyjia
 * Date: 11/15/13
 * Time: 10:23 AM
 */
public class CheckBoxActivity extends Activity {

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.checkbox);
        CheckBox fishCB = (CheckBox) findViewById(R.id.fishCB);
        if (fishCB.isChecked())
            fishCB.toggle();
        // flips the checkbox to unchecked if it waschecked
        fishCB.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
                        Log.v("CheckBoxActivity", "The fish checkbox is now "
                                + (isChecked ? "checked" : "not checked"));
                    }
                });
    }
}
